package com.tamtamy.jtta.test.junit;


import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import com.tamtamy.jtta.JTTAClient;
import com.tamtamy.jtta.data.*;
import com.tamtamy.jtta.exception.JTTAException;

public class UnitTestJSON {
	
	private static String URL = "http://testapi.tamtamy.com/tamtamy/api";
	private static String USERNAME = "testapi";
	private static String PASSWORD = "testapi";
	
	JTTAClient tta;

	@Before
	public void setUp() throws Exception {
		tta = new JTTAClient(URL, USERNAME, PASSWORD, "", "JSON", true, false);
	}
	
	@Test
	public void testAPI() throws JTTAException {
		tta.doLogin();
		int limit = 5;
		{
			ContentList items = tta.getContentList(0, limit, "", "");
			for (Content item : items) {
				System.out.println(item);
			}
			Assert.assertEquals("content list size", items.size(), limit);
		}
		{
			CommentList items = tta.getCommentList(0, limit);
			for (Comment item : items) {
				System.out.println(item);
			}
			Assert.assertEquals("comment list size", items.size(), limit);
		}
		{
			NetworkList items = tta.getNetworkList(0, 1);
			for (Network item : items) {
				System.out.println(item);
			}
			Assert.assertEquals("netowork list size", items.size(), 1);
		}
		{
			TagList items = tta.getTagList(0, limit);
			for (Tag item : items) {
				System.out.println(item);
			}
			Assert.assertEquals("tag list size", items.size(), limit);
		}
		{
			GroupList items = tta.getGroupList(0, 1);
			for (Group item : items) {
				System.out.println(item);
			}
			Assert.assertEquals("group list size", items.size(), 1);
		}
		/*
		{
			NoticeList items = tta.getNoticeList(0, limit, "");
			for (Notice item : items) {
				System.out.println(item);
			}
			Assert.assertEquals("notice list size", items.size(), limit);
		}
		*/
		{
			OnLineUsersList items = tta.getOnLineUsersList(0, 1);
			for (OnlineUser item : items) {
				System.out.println(item);
			}
			Assert.assertEquals("online user list size", items.size(), 1);
		}
		{
			UsersList items = tta.getUsersList(0, 1, "");
			for (User item : items) {
				System.out.println(item);
			}
			Assert.assertEquals("notice list size", items.size(), 1);
		}
		{
			UserStatsGenerationList items = tta.getUserStatsGenerationList(0, limit);
			for (UserStatsGeneration item : items) {
				System.out.println(item);
			}
			Assert.assertEquals("notice list size", items.size(), limit);
		}
	}

}
